//
//  JRViewController.m
//  PanKe--Mr_wang
//
//  Created by 王博文1 on 2016/12/5.
//  Copyright © 2016年 sweets. All rights reserved.
//

#import "JRViewController.h"

@interface JRViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    NSArray *arr1;
    UISegmentedControl *seg;
    UIView *view;
    
}
@property(nonatomic,strong)UITableView *tabview;
@end

@implementation JRViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    view =[[UIView alloc]initWithFrame:CGRectMake(0, 50, (self.view.frame.size.width-55)/4, 4)];
    [view setBackgroundColor:[UIColor greenColor]];
    
    
    arr1=@[@"碎片",@"今日",@"动态",@"生活"];
    seg=[[UISegmentedControl alloc]initWithItems:arr1];
    seg.frame=CGRectMake(0, 15, self.view.frame.size.width-55, 35
                         );
  
    //设置test控件的颜色为透明
    seg.tintColor=[UIColor clearColor];
    //定义选中状态的样式selected，类型为字典
    NSDictionary *selected = @{NSFontAttributeName:[UIFont systemFontOfSize:20],
    NSForegroundColorAttributeName:[UIColor greenColor]};
    //定义未选中状态下的样式normal，类型为字典
    NSDictionary *normal = @{NSFontAttributeName:[UIFont systemFontOfSize:20],
                             NSForegroundColorAttributeName:[UIColor grayColor]};
    
    /*
     NSFontAttributeName -> 系统宏定义的特殊键，用来给格式字典中的字体赋值
     NSForegroundColorAttributeName -> 系统宏定义的特殊键，用来给格式字典中的字体颜色赋值
     */
    
    //通过setTitleTextAttributes: forState: 方法来给test控件设置文字内容的格式
    [seg setTitleTextAttributes:normal forState:UIControlStateNormal];
    [seg setTitleTextAttributes:selected forState:UIControlStateSelected];
    [seg addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventTouchDown];
    
    [self.view addSubview:seg];
    self.view.backgroundColor=[UIColor whiteColor];
    
    
    
    UIButton *butt=[UIButton buttonWithType:UIButtonTypeCustom];
    butt.frame=CGRectMake(self.view.frame.size.width-55, 15, 40, 40);
   
    [butt setBackgroundImage:[UIImage imageNamed:@"7.jpg"] forState:UIControlStateNormal];
    [butt addTarget:self action:@selector(geReng) forControlEvents:UIControlEventTouchUpInside];
    butt.layer.masksToBounds=YES;
    butt.layer.cornerRadius=20;
    butt.backgroundColor=[UIColor yellowColor];
    
    
            [self.view addSubview:butt];
    [self mitableview];
[self.view addSubview:view];
// 	   self.navigationController.navigationBar.tintColor=[UIColor     
    // Do any additional setup after loading the view.
}
//- (void)scrollViewDidScroll:(UIScrollView *)scrollView
-(void)mitableview
{
    if (_tabview ==nil) {
        _tabview=[[UITableView alloc]initWithFrame:CGRectMake(0, 59, self
                                                              .view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
        _tabview.dataSource=self;
        _tabview.delegate=self;
        
    }
   
    [self.view addSubview: _tabview];

}
-(void)segmentAction:(UISegmentedControl *)segment
{
    CGFloat x=(self.view.frame.size.width-55)/4 * segment.selectedSegmentIndex;
    [UIView animateWithDuration:0.2 animations:^{
        view.frame=CGRectMake(x, 50, (self.view.frame.size.width-55)/4, 4);
    }];


}

-(void)geReng
{


}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
//添加表格的方法*************************************************************
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 40;
    

}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *str =@"sss";
    UITableViewCell *Ceel=[tableView dequeueReusableCellWithIdentifier:str];
    if (Ceel==nil) {
        Ceel=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:str];
        
    }

Ceel.textLabel.text=@"dashcbao";




    return Ceel;

}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
